<template>
	<view class="reply-container">
		<view style="padding: 20rpx;">
			<view class="toast-top">
				<view class="flex">
					<text style="color: red;">*</text>
					<view class="desc">转派人员</view>
				</view>
				
			</view>
			<view class="c-input">
				<!-- <text @click="handleTap('picker')" :class="{color: label === '请选择转派人员'}">{{label}}</text>
				<lb-picker ref="picker" mode="selector" :list="workerList" :dataset="{ name: 'label' }"
				 @change="handleChange" @confirm="handleConfirm" @cancel="handleCancel">
				</lb-picker> -->
				<song-data-picker :bigText="true" :noPadding="true" placeholder="请选择转派人员" :showArrow="false" :border="false" ref="songPicker" :localdata="workerList" popup-title="请选择" :openSearch="true" @change="onChange" @nodeclick="onnodeclick"></song-data-picker>
			</view>
			<!-- <view @click="toChoose(query,3)" class="c-input">
				<text v-if="!params['转派人员']" style="color: #808080;">请选择转派人员</text>
				<text v-else>{{params['转派人员']}}</text>
			</view> -->
			<view class="toast-top">
				<view class="flex">
					<text style="color: red;">*</text>
					<view class="desc">转派原因</view>
				</view>
			</view>
			<!-- <view class="title"><text style="color: red;">*</text>评价描述</view> -->
			<textarea style="height: 360rpx;" v-model="params['转派原因']" class="content" placeholder="请输入转派原因..." name="" id="" cols="30" rows="10"></textarea>
		</view>
		<button class="btn" @click="submit">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isChoose: [],
				query: [],
				workerList: [],
				params: {
					转派人员: null,
					任务id: null,
					转派人员id: null,
					被转派人员id: null,
					转派原因: ''
				},
				params1: {
					orgId: this.$config.groupId,
					pagination: {
						current: 1,
						pageSize: 100
					},
					sorter: {
						field: "id",
						order: 0
					}
				}
			}
		},
		onLoad(options) {
			this.params.任务id = +options.id
			this.params.被转派人员id = +options.personId
			this.getOperatorList()
		},
		methods: {
			getOperatorList() {
				// this.params1.单位id = uni.getStorageSync('currentUnitId')
				this.$http.post('/sys/user/list', this.params1).then(res => {
					console.log(res, '处理人员')
					if (res.code === 10000) {
						if (res.data.list !== null) {
							res.data.list.forEach(item => {
								item.value = item.id
								item.text = item.name
							})
						}
						this.workerList = res.data.list.filter(item => item.id !== uni.getStorageSync('userInfo').id)
					}
				})
			},
			toChoose(item, type) {
				let items = this.isChoose.length > 0 ? JSON.stringify(this.isChoose) : JSON.stringify(this.query)
				uni.navigateTo({
					url: `../chooseAssign/chooseAssign?item=${items}&type=${type}`
				})
			},
			onchange(e) {
				this.params.附件 = e
			},
			onChange(e) {
				this.params.转派人员id = e.detail.value
			},
			// onChange(e) {
			// 	console.log('rate发生改变:' + JSON.stringify(e))
			// 	console.log(this.rateValue)
			// },
			submit() {
				if (!this.params.转派人员id) {
					uni.showToast({
						title: '请选择转派人员',
						icon: 'none'
					})
				} else if (this.params.转派原因.trim() == '') {
					uni.showToast({
						title: '请填写转派原因',
						icon: 'none'
					})
				} else {
					this.evaluate()
				}
			},
			evaluate() {
				console.log(this.params)
				uni.showLoading({
					mask: true
				})
				this.$http.post('taskSystem/task/assign', this.params).then(res => {
					console.log(res)
					if (res.code === 10000) {
						uni.redirectTo({
							url: '/ticketSystem/acceptSuccess/acceptSuccess?path=/taskSystem/index/index' + '&title=返回任务首页'
						})

						// uni.redirectTo({
						// 	url: '../success/success?path=../ticketDetail/ticketDetail&title=查看评价内容' + '&id=' + this.params.id
						// })
						
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.reply-container {

		// padding: 20rpx;
		.flex {
			display: flex;
			align-items: center;
		}

		.title {
			margin-bottom: 30rpx;
		}
		.c-input {
			padding-left: 20rpx;
			border: 2rpx solid #ccc;
			height: 70rpx;
			display: flex;
			align-items: center;
		}
		.content {
			width: 710rpx;
			padding: 20rpx;
			border: 2rpx solid #ccc;
		}

		.btn {
			width: 568rpx;
			height: 80rpx;
			line-height: 80rpx;
			margin-top: 200rpx;
			background-color: #1152FC;
			color: #fff;
		}

		.toast-top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 20rpx;
			margin-top: 20rpx;
			.desc {
				margin-right: 20rpx;
				font-size: 36rpx;
			}

			.desc-text {
				color: #BCBCBC;
				font-size: 30rpx;
				margin-left: 18rpx;
			}
		}
	}
</style>
